<template>
<div>
  <h1>新闻展示</h1>
  <table>
    <tr>
      <td>标题</td>
      <td>评论数</td>
      <td>浏览数</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in list">
      <td>{{i.title}}</td>
      <td>{{i.count}}</td>
      <td>{{i.liucount}}</td>
      <td>
        <button @click="axq(i.id)">详情</button>
      </td>
    </tr>
  </table>

</div>
</template>

<script>
export default {
  name: "anews",
  data(){
    return{
      list:[],
      userid:localStorage.getItem('userid')
    }
  },
  methods:{
    show(){
      this.$axios.get('users/Ausers_API/')
      .then(i=>{
        this.list = i.data.list
      })
    },
    axq(id){
      if (this.userid){
        this.$router.push({path:'/apl',query:{id:id}})
      }
      else {
        this.$router.push('alogin/')

      }
    }
  },
  mounted() {
    this.show()
  }
}
</script>

<style scoped>

</style>
